package com.jy.rhin.parse;


import com.jy.rhin.infra.cda.XPath;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.select.Elements;
import org.seimicrawler.xpath.JXNode;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
/**
 * @Author 姚俊
 * @Date 2023/2/17 15:05
 * @Description
 */
@Component
@Slf4j
public class ItemTextSelector implements Selector {

    @Override
    public String selectValue(JXNode root, XPath xPath) {
        Elements elements = root.asElement().getElementsByTag("text");
        if (!CollectionUtils.isEmpty(elements)) {
            return elements.get(0).text();
        } else {
            log.warn("无法获取text节点,{}", root);
            return "";
        }
    }

}
